package com.qidianit.mes.md.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.md.service.WorkShopService;
import com.qidianit.mes.pojo.WorkShop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 奇幻夜之梦
 * @Company 起点编程
 * @Description
 * @Time 2024/10/24 19:42
 */
@CrossOrigin // 允许跨域请求
@RestController
@RequestMapping("/workshop")
public class WorkShopController {
    @Autowired
    private WorkShopService workShopService;
    @GetMapping("/list")
    public MESResult selectByPage(WorkShop workShop,
                                  @RequestParam(defaultValue = "1")int page,
                                  @RequestParam(defaultValue = "10")int limit){
        // 这里只有一行代码，直接调用service，不处理任何业务
        return workShopService.selectByPage(workShop,page,limit);
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody WorkShop workShop) {
        return  workShopService.save(workShop);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody WorkShop workShop) {
        return workShopService.updateWorkShop(workShop);
    }

    @GetMapping("selectById")
    public MESResult selectById(Long workShopId) {
        return workShopService.selectById(workShopId);
    }

    @DeleteMapping("/delete")
    public MESResult delete(Long workShopId){
        return workShopService.delete(workShopId);
    }

    @DeleteMapping("/deletes")
    public MESResult deletes(String [] workShopId){
        return workShopService.deletes(workShopId);
    }

    @GetMapping("/listWorkShops")
    public MESResult listWorkShops() {
        return workShopService.listWorkShops();
    }
}

